<?php include_once './application/views/sys_admin/common/header.php';  ?>
<?php 
$colorArr = array(1=>'金',2=>'银',3=>'铜',4=>'铁',5=>'木');
$awardType = array(0=>'无',1=>'积分',2=>'商品',3=>'VIP',4=>'再来一次');
?>


<!-- admin_main -->
<div class="admin_main">
	<!-- Admin_top end -->
	<?php include_once './application/views/sys_admin/common/shop_left.php';  ?>
	<!-- Admin_Left End -->
	<div class="admin_right">
		<div class="admin_right_title">
			<strong>商城管理</strong> &gt;&gt;  抽奖记录
		</div>
		<div class="admin_right_con" style="width: 98%">
			<table border="0" cellspacing="1" cellpadding="0" bgcolor="#CCCCCC" width="100%">
			  <tr style="color:#0068b7;">
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>编号</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>用户名</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>箱子颜色</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>打开积分</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>是否打开</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>奖励类型</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>奖励商品</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>奖励积分</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>时间</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>状态</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>操作</strong></td>
			  </tr>
			  <?php foreach($list as $info){?>
			  <tr>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['id'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['username'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $colorArr[$info['box_color']];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['open_credit'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['is_open'] ? '已打开':'未打开';?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $awardType[$info['award_type']];if ($info['award_type']==3){echo $info['vip_time']/(3600*24)."天";}?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['pname'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['credit_value'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo date('Y-m-d H:i',$info['add_time']);?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['fstatus']==1?"已发货":"<span style='color:red'>未发货</span>";?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php if ($info['award_type']==2 && $info['fstatus']==0){?><a href="javascript:fahuo(<?php echo $info['id'];?>);">确认发货</a><?php }else{?>--<?php }?></td>
			  </tr>
			  <?php }?>
			  <tr>
			  	<td colspan="10"  height="35" align="left" valign="middle" bgcolor="#FFFFFF">
			  		<form id="searchForm" action="/sys_admin/shop/box_list" method="get">
			  			用户名：<input type="text" id="username" name="username" style="width: 100px;" value="<?php echo $where['username'];?>" />
			  			状态：<select id="fstatus" name="fstatus">
			  				<option value="-1" <?php if($where['fstatus']==-1){?>selected="selected"<?php }?>>所有</option>
			  				<?php foreach($statusArr as $key=>$value){?>
			  				<option value="<?php echo $key?>" <?php if($where['fstatus']==$key){?>selected="selected"<?php }?>><?php echo $value;?></option>
			  				<?php }?>
			  			</select>
			  			奖励类型：<select id="award_type" name="award_type">
			  				<?php foreach($awardType as $key=>$value){?>
			  				<option value="<?php echo $key?>" <?php if($where['award_type']==$key){?>selected="selected"<?php }?>><?php echo $value;?></option>
			  				<?php }?>
			  			</select>
			  			
			  			下单时间：<input type="text" id="strtime" name="strtime" readonly="readonly" style="width: 100px;" value="<?php echo $where['strtime'];?>"  onfocus="WdatePicker()" />
			  			--<input type="text" id="endtime" name="endtime" readonly="readonly" style="width: 100px;" value="<?php echo $where['endtime'];?>"  onfocus="WdatePicker()" />
			  			<input type="submit" value="查询" />
			  		</form>
			  	</td>
			  	<td  align="right" valign="middle" bgcolor="#FFFFFF">
			  		<a href="/sys_admin/shop/box_list_excle/?username=<?php echo $where['username'];?>&fstatus=<?php echo $where['fstatus'];?>&award_type=<?php echo $where['award_type'];?>&strtime=<?php echo $where['strtime'];?>&endtime=<?php echo $where['endtime'];?>">导出数据</a>
			  	</td>
			  </tr>
			  <tr>
			  	<td  height="35" colspan="12" align="center" class="page" bgcolor="#FFFFFF"><?php echo $this->pagination->create_links();?></td>
			  </tr>
			</table>
			
			</div>
	</div>
<!-- Admin_Right End -->
</div>
<form id="tmpform"></form>
<script>
function fahuo(id){
	$('#dialog').dialog({
		modal:true,
		title:'系统提示',
		buttons:{"确定":function(){
			var options = {
				url : '/sys_admin/shop/boxfahuo/'+id,
				dataType: "text",
				type:"get",
				success : function(msg) {
					$('#dialog').dialog({
						modal:true,
						title:'系统提示',
						buttons:{"确定":function(){$(this).dialog("close");}},
						close: function() {
							location.reload();
						}
					}); 
					$("#msg").html(msg);
				}
			};
			$('#tmpform').ajaxSubmit(options);
		},
		"取消":function(){$(this).dialog("close");}}
	}); 
	$("#msg").html("确认已经发货吗？");

}
</script>
<div id="dialog" title="系统提示" style="display:none;">
<div id="msg" style="text-align:center;color:red">&nbsp;</div>
</div>
<!-- admin_main end -->
</body>
</html>
